<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎登录</title>
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script>
        function dologin() {
            $.ajax({
                url:"/dologin",
                type:"post",
                dataType:"json",
                data:{
                    "username":$("#username").val(),
                    "password":$("#password").val(),
                    "captcha":$("#captcha").val()
                },
                success:function (result) {
                    if (result.errorCode==200){
                        location.href="/pages/ajax.html"
                    }else {
                        alert(result.errorMsg);
                    }
                }
            })
        }
        function getcapt() {
            $("#imgcapt").prop("src","/kaptcha?="+Math.random());
        }
    </script>
</head>
<body>
<h3>管理员登录</h3>
<form name="frmlogin">
    账号:<input type="text" name="username" id="username"/><br/>
    密码:<input type="password" name="password" id="password"/><br/>
    验证码:<input type="text" name="captcha" id="captcha"/><img id="imgcapt" src="/kaptcha" onclick="getcapt()"><br/>
    <input type="button" value="登录" name="btnlogin" onclick="dologin()"/>
    <input type="reset" value="重置" name="btnreset"/>
</form>
</body>
</html>